<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增用户')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form id="form-user-add" class="form-horizontal">

            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">开始编号：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="  form-control" placeholder="请输入文本" >
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">管长：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">m</div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">管径：</label>
                        <div class="col-sm-6 input-group">
                            <select class="form-control" name=""></select>
                            <div class="input-group-addon">in</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">管径：</label>
                        <div class="col-sm-6 input-group">
                            <select class="form-control" name=""></select>
                            <div class="input-group-addon">mm</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">扣型：</label>
                        <div class="col-sm-6 input-group">
                            <select class="form-control" name=""></select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">钢级：</label>
                        <div class="col-sm-6 input-group">
                            <select class="form-control" name=""></select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">壁厚：</label>
                        <div class="col-sm-6 input-group">
                            <select class="form-control" name=""></select>
                            <div class="input-group-addon">mm</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">最大扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">最佳扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">最小扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">记录扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">控制扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">报警扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">满屏扭矩：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">kN.m</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">满屏时间：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                            <div class="input-group-addon">S</div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="form-group">
                        <label class="col-sm-5 control-label">满屏圈数：</label>
                        <div class="col-sm-6 input-group">
                            <input type="text" name="" class="form-control" placeholder="请输入文本" >
                        </div>
                    </div>
                </div>
            </div>


        </form>
    </div>
      
    <div class="row">
        <div class="col-sm-offset-5 col-sm-12">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保存管件信息</button>&nbsp;
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保存工作参数</button>&nbsp;
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script>
	    var prefix = ctx + "system/user";
	
        $("#form-user-add").validate({
        	onkeyup: false,
        	rules:{
        		loginName:{
        			minlength: 2,
        			maxlength: 20,
        			remote: {
                        url: prefix + "/checkLoginNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	"loginName": function() {
                                return $.common.trim($("#loginName").val());
                            }
                        },
                        dataFilter: function(data, type) {
                        	return $.validate.unique(data);
                        }
                    }
        		},
        		password:{
        			minlength: 5,
        			maxlength: 20
        		},
        		email:{
                    email:true,
                    remote: {
                        url: prefix + "/checkEmailUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "email": function () {
                                return $.common.trim($("#email").val());
                            }
                        },
                        dataFilter: function (data, type) {
                        	return $.validate.unique(data);
                        }
                    }
        		},
        		phonenumber:{
        			isPhone:true,
                    remote: {
                        url: prefix + "/checkPhoneUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "phonenumber": function () {
                                return $.common.trim($("#phonenumber").val());
                            }
                        },
                        dataFilter: function (data, type) {
                        	return $.validate.unique(data);
                        }
                    }
        		},
        	},
        	messages: {
                "loginName": {
                    remote: "用户已经存在"
                },
        		"email": {
                    remote: "Email已经存在"
                },
        		"phonenumber":{
                	remote: "手机号码已经存在"
        		}
            },
            focusCleanup: true
        });
        
        function submitHandler() {
        	var chrtype = [[${#strings.defaultString(@config.getKey('sys.account.chrtype'), 0)}]];
			var password = $("#password").val();
	        if ($.validate.form() && checkpwd(chrtype, password)) {
	        	var data = $("#form-user-add").serializeArray();
	        	var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
	        	var roleIds = $.form.selectCheckeds("role");
	        	var postIds = $.form.selectSelects("post");
	        	data.push({"name": "status", "value": status});
	        	data.push({"name": "roleIds", "value": roleIds});
	        	data.push({"name": "postIds", "value": postIds});
	        	$.operate.saveTab(prefix + "/add", data);
	        }
	    }
         
        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
        	var treeId = $("#treeId").val();
        	var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        	var url = ctx + "system/dept/selectDeptTree/" + deptId;
			var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var tree = layero.find("iframe")[0].contentWindow.$._tree;
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}

		$(function() {
            $('#post').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        })
    </script>
</body>
</html>